package com.example.service.shopping;


import com.example.mapper.shopping.MedicinesTypeMapper;
import com.example.model.entity.shopping.MedicinesType;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 药物分类表业务处理
 **/
@Service
public class MedicinesTypeService {

    @Resource
    private MedicinesTypeMapper medicinesTypeMapper;

    /**
     * 新增
     */
    public void add(MedicinesType medicinesType) {
        medicinesTypeMapper.insert(medicinesType);
    }

    /**
     * 删除
     */
    public void deleteById(Integer id) {
        medicinesTypeMapper.deleteById(id);
    }

    /**
     * 批量删除
     */
    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            medicinesTypeMapper.deleteById(id);
        }
    }

    /**
     * 修改
     */
    public void updateById(MedicinesType medicinesType) {
        medicinesTypeMapper.updateById(medicinesType);
    }

    /**
     * 根据ID查询
     */
    public MedicinesType selectById(Integer id) {
        return medicinesTypeMapper.selectById(id);
    }

    /**
     * 查询所有
     */
    public List<MedicinesType> selectAll(MedicinesType medicinesType) {
        return medicinesTypeMapper.selectAll(medicinesType);
    }

    /**
     * 分页查询
     */
    public PageInfo<MedicinesType> selectPage(MedicinesType medicinesType, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MedicinesType> list = medicinesTypeMapper.selectAll(medicinesType);
        return PageInfo.of(list);
    }

}
